package com.hdsx.restful.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * easyui的分页查询类
 * @author wusq
 *
 * @param <T>
 */
public class EasyUI<T>  implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 总记录数
	 */
	private int total;
	/**
	 * 每页数据
	 */
	private List<T> rows;
	private int limit;
	private int start;
	private int begin;
	private int end;
	private Map<String,Object> parameter;
	public EasyUI(){
		parameter=new HashMap<String,Object>();
	}
	public EasyUI(int start,int limit)
	{
		this();
		if(start < 1){
			start = 1;
		}
		if(limit < 1){
			limit = 10;
		}
		this.limit = limit;
		this.start = start;
		this.begin=(start-1)*limit;
		this.end=start*limit;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
	public List<T> getRows() {
		return rows;
	}
	public void setRows(List<T> rows) {
		this.rows = rows;
	}
	public int getBegin() {
		return begin;
	}
	public void setBegin(int begin) {
		this.begin = begin;
	}
	public int getEnd() {
		return end;
	}
	public void setEnd(int end) {
		this.end = end;
	}
	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public void put(String key,Object value) {
		parameter.put(key, value);
	}
	public Map<String, Object> getParameter() {
		parameter.put("begin",begin);
		parameter.put("end", end);
		return parameter;
	}
}
